package com.app.service.impl;

import com.app.mapper.jiuquan.EminentPersonMapper;
import com.app.model.EminentPersonModel;
import com.app.service.EminentPersonService;
import com.app.util.StringTool;
import com.app.vo.EminentPersonVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

//创业达人
@Service
public class EminentPersonServiceImpl extends ServiceImpl<EminentPersonMapper, EminentPersonModel> implements EminentPersonService {
    @Autowired
    private EminentPersonMapper eminentPersonMapper;
    //查询创业达人列表
    @Override
    public EminentPersonVo getEminentPersonList(Integer page, Integer limit, String name) {
        Page<EminentPersonModel> page1 = new Page<>(page, limit);
        QueryWrapper<EminentPersonModel> qw =new QueryWrapper<>();
        if (StringTool.isNotEmpty(name)){
            qw.like("name",name);
        }
        Page<EminentPersonModel> eminentPersonPage = eminentPersonMapper.selectPage(page1, qw);
        List<EminentPersonModel> eminentPersonList = eminentPersonPage.getRecords();
        long count = eminentPersonPage.getTotal();
        EminentPersonVo eminentPersonVo = new EminentPersonVo();
        eminentPersonVo.setList(eminentPersonList);
        eminentPersonVo.setCount((int) count);
        return eminentPersonVo;
    }
}
